package com.ruoyi.web.controller.system;

import cn.hutool.core.util.RandomUtil;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.SendSmsUtil;
import com.ruoyi.system.service.ImLoginService;
import org.apache.commons.lang3.ObjectUtils;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/im/app")
public class ImLoginController {

    @Autowired
    private ImLoginService imLoginService;

    @Autowired
    private RedisCache redisCache;

    @PostMapping("/login")
    public AjaxResult imLogin(@RequestBody LoginBody loginBody){
        Map<String,Object> map=imLoginService.imLogin(loginBody);
        return AjaxResult.success(map);
    }

    /**
     * 注销删除用户
     * @return
     */
    @PostMapping("/deleteUser")
    public AjaxResult deleteUser(@RequestBody LoginBody loginBody){
        imLoginService.imDeleteUser(loginBody);
        return AjaxResult.success();
    }

    /**
     * 发送验证码
     *
     * @param request
     * @return
     */
    @PostMapping("/sendCode")
    public AjaxResult sendCode(@RequestBody SendSmsUtil.SendSmsRequest request){

        return imLoginService.sendCode(request);

    }

    /**
     * 注册
     * @param request
     * @return
     */
    @PostMapping("/register")
    public AjaxResult register(@RequestBody SendSmsUtil.SendSmsRequest request){
        return imLoginService.imRegister(request);
    }

//
//    /**
//     * 忘记密码
//     * @param request
//     * @return
//     */
//    @PostMapping("/forgetPassword")
//    public AjaxResult forgetPassword(@RequestBody SendSmsUtil.SendSmsRequest request){
//        System.out.println(request);
//        return imLoginService.forgetPassword(request);
//    }
}
